package com.cke.yang.security.api.controller;

import com.cke.yang.common.domain.model.Result;
import com.cke.yang.security.api.dto.response.SecAuthLoginResponse;
import com.cke.yang.security.app.service.SecAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 安全模块-认证控制器
 *
 * @author yuyang
 */
@RestController
@RequestMapping("/api/security/sec-auth")
public class SecAuthController {

    @Autowired
    private SecAuthService secAuthService;

    /**
     * 登录
     */
    @PostMapping("/login")
    public Result<SecAuthLoginResponse> login(@RequestParam(value = "type", defaultValue = "Basic", required = false) String type,
                                              @RequestBody Map<String, String> bodyMap) {
        SecAuthLoginResponse response = secAuthService.login(type, bodyMap);
        return Result.success(response);
    }

}
